package com.zzwc.vote.www.web;

import com.zzwc.vote.utils.IPUtils;
import com.zzwc.vote.utils.R;
import com.zzwc.vote.www.service.IVoteTerritoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
public class VoteTicketController {

    @Autowired
    private IVoteTerritoryService voteTerritoryService;

    /**
     * @author jetlag
     * @param request
     * @param response
     * @param openId
     * @param companyId
     * @return
     */
    @RequestMapping("/tiket/cast")
    public R cast(HttpServletRequest request, HttpServletResponse response,
                  @RequestParam("open_id") String openId,
                  @RequestParam("company_id") String companyId) {
        String ip=IPUtils.getIpAddr(request);
        voteTerritoryService.castVote(openId,companyId,ip);
        return R.ok("投票成功");
    }

}

